package com.itheima.health.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.vo.CheckGroupVO;
import com.itheima.health.vo.SetmealVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {

    @Delete("delete from t_setmeal_checkgroup where SETMEAL_ID = #{id}")
    void relieveBySetmealId(@Param("id") Integer id);

    @Insert("insert into t_setmeal_checkgroup values(#{SETMEAL_ID},#{checkgroupId})")
    void addSetmealAndCheckgruopIds(@Param("SETMEAL_ID") Integer id, @Param("checkgroupId") Integer checkgroupId);

    @Select("select CHECKGROUP_ID from t_setmeal_checkgroup where SETMEAL_ID = #{SETMEAL_ID}")
    List<Integer> findCheckGruopIdsBySetmealId(@Param("SETMEAL_ID") int id);

    @Select("select * from t_Setmeal where id = #{id}")
    SetmealVO findSetmealById(@Param("id") Integer id);

    @Select("SELECT tc.name,tc.id,tc.REMARK from  t_setmeal_checkgroup tsc , t_checkgroup tc where tsc.CHECKGROUP_ID = tc.ID and tsc.SETMEAL_ID = #{id}")
    List<CheckGroupVO> findCheckGroupsBySetmealId(@Param("id") Integer id);


}
